package com.koushikdutta.async.parser;

import com.koushikdutta.async.DataEmitter;
import com.koushikdutta.async.future.Future;
import com.koushikdutta.async.future.TransformFuture;
import org.json.JSONObject;

public class JSONObjectParser implements AsyncParser<JSONObject> {
    public Future<JSONObject> parse(DataEmitter emitter) {
        return (Future) new StringParser().parse(emitter).then(new TransformFuture<JSONObject, String>() {
            protected void transform(String result) throws Exception {
                setComplete((Object) new JSONObject(result));
            }
        });
    }
}
